package com.yuchuang.utils;

/**
 * @Author:cy Date: 2023-06-20-10:26
 * Description:
 * codeType:编号前缀   YCSH
 * codeStr: 数据   YCSH-000000001   默认9位   亿
 */
public class Utils {
    public Utils(){};
    public static String getCode(String codeType,String codeStr){
        String strCode = "";
        String[] strArr = codeStr.split("-");
        if(!codeType.isEmpty() && !codeStr.isEmpty() && strArr.length == 2 ){
            int codeNum = Integer.parseInt(strArr[1]);
            ++codeNum;
            strCode = String.format(codeType+"-"+"%09d",codeNum);
        }else{
            strCode = codeType+"-"+"000000001";
        }
        return strCode;
    }
    public static String getCode(String codeStr){
        String strCode = "";
        if(!codeStr.isEmpty()){
            String[] strArr = codeStr.split("-");
            int codeNum = Integer.parseInt(strArr[1]);
            ++codeNum;
            strCode = String.format("YCSC"+"-"+"%09d",codeNum);
        }else{
            strCode = "YCSC"+"-"+"000000001";
        }
        return strCode;
    }
}
